<include file="__PUBLIC__/_header" />
<body>
<link rel="stylesheet" href="__APP_SKIN__css/newInformation.css">
<link rel="stylesheet" href="__APP_SKIN__css/shopCart.css">
<link rel="stylesheet" href="__APP_SKIN__css/classification.css">
<link rel="stylesheet" href="__APP_SKIN__css/goodsDetails.css">
<script src="__APP_SKIN__js/cart.js?v=2223568333c44v"></script>
<script src="__APP_SKIN__js/ajax.js?v=311"></script>
<script src="__APP_SKIN__js/plugin/WdatePicker.js" type="text/javascript"></script>
<!--头部开始-->
<include file="__PUBLIC__/_nav" />
<!--头部结束-->
<style>
    .shopInfo .thd7{ width:300px}
</style>
<div class="shopInfo">
    <div class="shopInfo-head">
        <ul>
            <li style="margin: 0px;">订单客户：{:LoginHelper::getUserName()}</li>
            <li id="totalLineCount">单体行数：</li>
            <li id="totalProductCount1">总样数：</li>
            <li>订购金额:
                <span style="color: #19b1e3; font-weight: 600" id="payAmount1">0 元</span>
            </li>
        </ul>
    </div>
    <div class="SCsearchbox">
        <input type="text" value="购物车商品搜索" class="searchbox" onfocus="if(value=='购物车商品搜索'){value=''}" onblur="if(value==''){value='购物车商品搜索'}" maxlength="100">
        <input type="button" value="搜 &nbsp;&nbsp;索" class="suobox">
        <input type="button" value="清 &nbsp;&nbsp;空" class="qingkong" onclick="resetCart('{:LoginHelper::getUserId()}')" >
        <!--<input type="hidden" value="0.0000" id="MininumAmt" />-->
        <!--<div class="div888 L_div888"><input type="button" value="提交订单" onclick="submitOrderTimeout()" class="clsSubmit"></div>-->
    </div>

    <!-- 2016/9/7 购物车页面，添加促销活动下拉框开始-->



    <!-- 2016/9/7 购物车页面，添加促销活动下拉框结束-->

    <table class="shopcart" border="0" cellspacing="0" cellpadding="0" style="margin-top:10px;">
        <thead>
        <tr>
            <th class="thd1">序号</th>
            <th class="thd2">编码</th>
            <th class="thd3">商品名称</th>
            <th class="thd4" style="width: 90px">单位</th>
			<th class="thd6">配送规格</th>
            <th class="thd6">单价</th>
            <!-- <th class="thd6">批发价</th>-->
            <th class="thd7">订购数量</th>
            <th class="thd8">小计</th>
            <th class="thd10">备注</th>
            <th class="thd11">操作</th>
        </tr>

        </thead>
    </table>
    <div class="shopscolldiv">
        <table class="shopcart" border="0" cellspacing="0" cellpadding="0" id="cartTable">
            <thead id="tbody">
            <if condition="!$data">
                <td colspan="11" style="text-align: left;color: #19b1e3; padding-left: 20px; padding-top: 20px;font-size: 16px;">购物车空空如也</td>
                <else/>
                <volist name="data" id="vo">
                    <if condition="$vo.m_spec eq 0">
                        <tr id="tr_{$vo.m_id}" class="ck"   data-totalnum="{:($vo['total'])}" data-chasedo_spec="{$vo.chasedo_spec}"  data-mprice="{$vo.m_min_price}"  data-mname="{$vo.m_name}" data-bid="{$vo.b_id}" data-mid="{$vo.m_id}"  data-price="{$vo.m_price}" >
                        <else/>
                        <tr id="tr_{$vo.m_id}" class="ck"   data-totalnum="{$vo.total}" data-chasedo_spec="{$vo.chasedo_spec}" data-mprice="{$vo.m_min_price}"  data-mname="{$vo.m_name}" data-bid="{$vo.b_id}" data-mid="{$vo.m_id}"  data-price="{$vo.price}" >
                        </if>
                        <td class="thd1">{$i}</td>
                        <td class="thd2">{$vo.m_id}</td>
                        <td class="thd3">
                            <a href="{:BaseController::_createUrl('index/detail',array('kid'=>$vo['m_id']))}">
                                <div class="shopName" style="width:100%;overflow:hidden;">
                                    <if condition="$vo.m_tag eq 1">
                                        <span class="Givegif Givegif2">促</span>
                                        <else/>
                                    </if>
                                    <div style="width: 120px;white-space:nowrap;overflow:hidden; text-overflow:ellipsis;" title="{$vo.m_name}">
                                        {$vo.m_name}
                                    </div>
                                </div>
                            </a>
                        </td>
                        <td style="width: 90px;">{$vo.tag_name}</td>
						<td style="width: 40px;">{$vo.chasedo_spec|round=2}</td>
                        <td class="thd6">{$vo.m_price}</td>
                       <!-- <td class="thd6">{$vo.m_price}</td>-->
                            <if condition="$vo.m_spec eq 999">
                                <td class="thd7">
                                <div class="number1" >																		
                                    <input type="number" value="{$vo.total}" class="h-jin" style=" width:50px; margin-right:0px;  display:inline;"> 斤
                                    <input type="number"  value="0" class="h-liang"  style=" width:50px; margin-right:0px;  display:inline;"> 两
                                    <input type="number" value="0" class="h-ke" style=" width:50px; margin-right:0px; display:inline;"> 克
                                    <input class="geprice" value="{$vo.m_min_price}" type="hidden" >
                                </div>

                        </td>
                        <td class="thd8 qian" style="text-align: right;">{:($vo['total']*$vo['m_price'])}</td>
                        <td class="thd10">
                            <input type="text" value="{$vo.remark}" maxlength="50" id="remark_{$vo.m_id}" class="inputly remark" >
                        </td>
                        <td class="thd11" width="60">
                            <p class="del" onclick="delCart('{:LoginHelper::getUserId()}','{$vo.m_id}')">删除</p>
                        </td>
                                <else />
                                <td class="thd7">
									<div class="number1"style="position: relative;">
										
										<div class="min subtract" style="display: inline-block;position: absolute;left: 119px;">-</div>
										<input type="hidden" id="hidId_{$vo.m_id}" value="{$vo.m_id}"/>
										<input class="text_box onlyint txtQty" style="" name=""  type="text" maxlength="6" 
										<if condition="$vo['chasedo_spec'] neq 1">
										readonly
										</if>										 
										onchange="preQtyChange({:LoginHelper::getUserId()},{$vo.m_id})"  value="{$vo.total}" />
										<div class="add" style="display: inline-block;position: absolute;">+</div>
										<input class="geprice" value="{$vo.m_price}" type="hidden" >
									</div>
                        </td>
                        <td class="thd8 qian" style="text-align: right;" data-price="{:($vo['total']*$vo['m_price'])}">{:($vo['total']*$vo['m_price'])}</td>
                        <td class="thd10">
                            <input type="text" value="{$vo.remark}" maxlength="50" id="remark_{$vo.m_id}" class="inputly remark" >
                        </td>
                        <td class="thd11" width="60">
                            <p class="del" onclick="delCart('{:LoginHelper::getUserId()}','{$vo.m_id}')">删除</p>
                        </td>
            </if>
                    </tr>
                </volist>
            </if>

            </thead>
        </table>
    </div>

    <table class="shopcart" border="0" cellspacing="0" cellpadding="0" style="background:#999; border-top:1px solid #CCC; margin-top:30px" id="tablehj">
        <thead>
        <tr>
            <th class="thd1">合计</th>
            <th class="thd2">&nbsp;</th>
            <th class="thd3">&nbsp;</th>
            <th class="thd4">&nbsp;</th>
            <th class="thd6">&nbsp;</th>
            <th class="thd6">&nbsp;</th>
            <th class="thd6">&nbsp;</th>
            <!--合计-->
            <th class="thd7" id="totalProductCount"></th>
            <th class="thd8" id="totalProductAmt" style="text-align: right;">0</th>
            <th class="thd10">&nbsp;</th>
            <th class="thd11">&nbsp;</th>
        </tr>
        </thead>
    </table>
    <p id="pchecked">
        <span style="margin-left: 20px;">配送日期：</span>
        <input id="d11" type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-{%d+1}'})" />
    </p>
    <p style="margin-top: 30px;">
        <span style="margin-left: 20px;">支付方式</span>
        <label class="h-tub nopay"><input type="radio"  checked name="pay"><span>货到付款</span></label>
    </p>
    <div class="button" id="zsbz1">
        <div class="L_clear"><input type="button" class="input1 input22" value="清空购物车" onclick="resetCart('{:LoginHelper::getUserId()}')" /></div>
        <div class="cart_remark"><dl><dt>整箱备注：</dt><dd><input id="remark" maxlength="500" value="" type="text"/></dd></dl></div>
        <input type="button" value="提交订单"  class="clsSubmit h-confirm">
    </div>
    <div class="money">
        <ul>
            <li style="margin: 0px;">商品总额：</li>
            <li id="totalProductAmt2" style="padding-right: 30px">0</li>
            <li style="float: right; margin-right: 15px;">订单总金额：
                <span style="color: #19b1e3; font-weight: 600" id="payAmount">0</span>
            </li>
        </ul>
    </div>
</div>


<!--2016/9/7 购物车页面,添加促销活动弹窗-->
<!--2016/9/7 购物车页面，背景色-->
<div class="all"></div>
<!--2016/9/7 购物车页面，A组商品+B组商品+C组商品-->
<div class="dialog" style="display: none;overflow: hidden;">
    <iframe src="" width="900" height="580" scrolling="no" frameborder="no" ></iframe>
    <div class="close" onclick="closeDialog()">
        <a>关闭</a>
    </div>
</div>
<input type="hidden" class="address" value="{$users.address}">
<input type="hidden" class="zonge" value="">
<input type="hidden" class="consignee" value="{$users.user_name}">
<input type="hidden" class="tel" value="{$users.mobile}">

<script type="text/javascript">
    var site_path = "{$shop_site_path}";
</script>
<div class="footer">
    <!--<p>湘ICP备13004873号-3 Copyright  芙蓉兴盛 2001-2016，All Rights Reserved </p>-->
    <!-- <p>监督热线：400-600-2200 企业QQ：400-6611-001</p>-->
</div>
</body>
<script>
    $(function(){
        var zonge='';
        getTotalPrice();
        var rq=GetDateStr(1);
        $("#d11").val(rq);
        $('.ck').each(function(){
            var remarke=$(this).find('.remark');
            var remark=remarke.val();
            $(this).attr("data-remark",remark);

        });
        $(".h-confirm").click(function(){
			if(!confirm("您确定要提交该订单吗,请不要重复提交订单")){
				return false;
			}
            var ids=[];		var len = 0;
            $('.ck').each(function(){
                var data='';
				var remark = '';
				if($(this).attr("data-remark") != ''){
					remark = $(this).attr("data-remark");
				}else{
					remark = $(this).find(".remark").val();
				}
                data={
                    'm_id':$(this).attr("data-mid"),
                    'total':$(this).attr("data-totalnum"),
                    'm_price':$(this).attr("data-mprice"),
                    "price": $(this).attr("data-price"),
					"m_price": $(this).attr("data-price"),
                    'b_id':$(this).attr("data-bid"),
                    'm_group_price':$(this).attr("data-price"),
                    'm_min_price':$(this).attr("data-price"),
                    'm_usual_price':$(this).attr("data-price"),
                    'm_name':$(this).attr("data-mname"),
                    'remark':remark,
                };
                ids.push(data);
            });
            ids=JSON.stringify(ids);
            var deliver_time= $("#d11").val();
            if(!deliver_time){
                layer.tips('请选择配送时间', '#d11', {
                    tips: 3
                });
                return false;
            }
           var tel=$(".tel").val();
            var address=$(".address").val(); var consignee=$(".consignee").val();
            var remark=$("#remark").val();
            var price = 0.0;
            $(".qian").each(function(){
                price =price + parseFloat($(this).html())
            })
            //总金额
            zonge=parseFloat(price).toFixed(2);
            var total=$("#cartTable tr").length;
            createOrderHttpHelper.create(ids,deliver_time,deliver_time,address,tel,consignee,zonge,total,remark);
        })

        $(".maintop .left .meun a").eq(3).addClass("active");
        //单体行数
        $("#totalLineCount").text("单体行数：" + $("#cartTable tr").length);
        //$("#totalProductCount").text( $("#cartTable tr").length);
        $("#totalProductCount1").text("总样数：" + $("#cartTable tr").length);




        $(".h-jin").change(function(){
            var jin=parseInt($(this).val())*500;var liang=parseInt($(this).siblings('.h-liang').val())*50;var ke=parseInt($(this).siblings('.h-ke').val());
            var total=jin+liang+ke; var price2=parseFloat($(this).siblings('input.geprice').val())/500;
            $(this).parents(".ck").attr("data-totalnum",total);
            var price = 0.0;var money=0.00;
            money=total*price2;
            $(this).parents(".thd7").siblings(".qian").html(money.toFixed(2));
            getTotalPrice();

        })

        $(".h-liang").change(function(){
            var liang=parseInt($(this).val())*50;var jin=parseInt($(this).siblings('.h-jin').val())*500;var ke=parseInt($(this).siblings('.h-ke').val());
            var total=jin+liang+ke; var price2=parseFloat($(this).siblings('input.geprice').val())/500; $(this).parents(".ck").attr("data-totalnum",total);
            var price = 0.0;var money=0.00;
                money=total*price2;
            $(this).parents(".thd7").siblings(".qian").html(money.toFixed(2));
            getTotalPrice();

        })
        $(".h-ke").change(function(){
            var ke=parseFloat($(this).val());var liang=parseFloat($(this).siblings('.h-liang').val())*50;var jin=parseFloat($(this).siblings('.h-jin').val())*500;
            var total=jin+liang+ke; var price2=parseFloat($(this).siblings('input.geprice').val())/500; $(this).parents(".ck").attr("data-totalnum",total);
            var price = 0.0;var money=0.00;
                money=total*price2;
            $(this).parents(".thd7").siblings(".qian").html(money.toFixed(2));
            getTotalPrice();
        })

        $(".txtQty").change(function(){
			var chasedo_spec = parseFloat($(this).parent().parent().parent().attr("data-chasedo_spec"));
            var qty = parseFloat($(this).val());    
			var price2=$(this).siblings('input.geprice').val(); 
			$(this).parents(".ck").attr("data-totalnum",qty);
            var money=0.00;
            money=parseFloat(qty)*price2;
            $(this).parents(".thd7").siblings(".qian").attr("data-price",money.toFixed(2));
			$(this).parents(".thd7").siblings(".qian").html(qty+"*"+chasedo_spec+"*"+price2+"="+money.toFixed(2));
            getTotalPrice();
        })

        $(".add").click(function(){
			var chasedo_spec = parseFloat($(this).parent().parent().parent().attr("data-chasedo_spec"));
			var m_id = ($(this).parent().parent().parent().attr("data-mid"));
            var qty = parseFloat($(this).siblings('.txtQty').val());
            $(this).siblings('.txtQty').val(qty+chasedo_spec);
            var price2=$(this).siblings('input.geprice').val();
            var html=   $(this).siblings('.txtQty').val();
            $(this).parents(".ck").attr("data-totalnum",html);
            var money=0.00;
            money=parseFloat(html)*price2;
			$(this).parents(".thd7").siblings(".qian").attr("data-price",money.toFixed(2));
            $(this).parents(".thd7").siblings(".qian").html((qty+chasedo_spec)+"*"+price2+"="+money.toFixed(2));
            getTotalPrice();
			refreshGoodsPrice(m_id,(qty+chasedo_spec),money.toFixed(2),price2);
        })

        $(".subtract").click(function(){
			var chasedo_spec = parseFloat($(this).parent().parent().parent().attr("data-chasedo_spec"));
			var m_id = ($(this).parent().parent().parent().attr("data-mid"));
            var qty = parseFloat($(this).siblings('.txtQty').val());
            var price2=$(this).siblings('input.geprice').val();
            if(qty <=1){
                alert("商品数量不能小于1");
                return;
            }
            $(this).siblings('.txtQty').val(qty-chasedo_spec);
            var html=$(this).siblings('.txtQty').val();
            $(this).parents(".ck").attr("data-totalnum",html);
                var money=0.00;
                money=parseFloat(html)*price2;
				$(this).parents(".thd7").siblings(".qian").attr("data-price",money.toFixed(2));
                $(this).parents(".thd7").siblings(".qian").html((qty-chasedo_spec)+"*"+price2+"="+money.toFixed(2));
                getTotalPrice();
				refreshGoodsPrice(m_id,(qty-chasedo_spec),money.toFixed(2),price2);
        })

    })
	
	function refreshGoodsPrice(m_id,total,price,m_price){
		//清空购物车
		$.ajax({
			url: site_path+"pcorder/index/refreshGoodsPrice",
			type: "post",
			data: { m_id: m_id, total:total, price:price , m_price:m_price},
			success: function (json) {
				var data = $.parseJSON(json);
				if (data.code == "200") {
					
				} else {
					
				}
			}
		});
	}
	
    function getTotalPrice(){
        var price = 0.0;
        $(".qian").each(function(){
            price =price + parseFloat($(this).attr("data-price"))
        })
        //总金额
        $("#payAmount1").text(parseFloat(price).toFixed(2) + " 元");
        $("#totalProductAmt").text(parseFloat(price).toFixed(2));
        $("#totalProductAmt2").text("￥" + parseFloat(price).toFixed(2));
        //订单总金额
        $("#payAmount").text("￥" + parseFloat(price).toFixed(2));
    }
    function GetDateStr(AddDayCount) {
        var dd = new Date();
        dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
        var y = dd.getFullYear();
        var m = dd.getMonth()+1;//获取当前月份的日期
        var d = dd.getDate();
        return y+"-"+m+"-"+d;
    }
</script>
</html>
